(function() {
    angular.module('BlurAdmin.pages.UserlistM')
        .controller('balanceCtrl', balanceCtrl);

    function balanceCtrl($scope, $openModal, $myconfig, $http, $datepicker, tongxin) {
        var user_id = tongxin.getUserInfo();



        $scope.search_opt = {
            "limit": 10,
            "page": 1,
            "user_id": user_id,
            "start_time": "",
            "end_time": "",
            "activityname": ""
        };
        //分页
        // $scope.bigTotalItems = 50;
        $scope.pageChanged = function(val) {
            var Page_num = val //选中的页面数
            $scope.search_opt.page = val;
            Search_list();
        };


        $scope.Search = function() { //获取用户理疗记录统计数据
            var data1 = document.getElementById("dat5") ? document.getElementById("dat5").value : null;
            var data2 = document.getElementById("dat6") ? document.getElementById("dat6").value : null;
            opt = $scope.search_opt;
            opt.start_time = data1;
            opt.end_time = data2;
            $http.get($myconfig.api.users_users_red_count, { params: opt }).then(function(res) {
                console.log(res.data.data);
                $scope.bigTotalItems = res.data.data;
                Search_list();
            })
        }

        function Search_list() { //获取用户理疗记录统计数据
            $http.get($myconfig.api.users_users_red_list, { params: opt }).then(function(res) {
                if (res.data.success) {
                    for (var i = 0; i < res.data.data.length; i++) { //添加条数属性
                        res.data.data[i].num = (($scope.search_opt.page - 1) * $scope.search_opt.limit) + i + 1;
                    }
                    $scope.list_data = res.data.data;
                }
                console.log($scope.list_data);
            })
        }
        $scope.Search();

    }
})();